﻿//StorageSettingsPanel.xaml.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Xaml
{
	using System.Windows;

	using Ookii.Dialogs.Wpf;

	using Ecng.Xaml;

	/// <summary>
	/// Визуальная панель настройки хранилища.
	/// </summary>
	public partial class StorageSettingsPanel
	{
		/// <summary>
		/// Создать <see cref="StorageSettingsPanel"/>.
		/// </summary>
		public StorageSettingsPanel()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Выбрано ли локальное хранилище.
		/// </summary>
		public bool IsLocal
		{
			get { return IsLocalCtrl.IsChecked == true; }
			set { (value ? IsLocalCtrl : IsRemoteCtrl).IsChecked = true; }
		}

		/// <summary>
		/// Путь к локальным данным.
		/// </summary>
		public string Path
		{
			get { return PathCtrl.Text; }
			set { PathCtrl.Text = value; }
		}

		/// <summary>
		/// Адрес удаленного хранилища.
		/// </summary>
		public string Address
		{
			get { return AddressCtrl.Text; }
			set { AddressCtrl.Text = value; }
		}

		/// <summary>
		/// Логин.
		/// </summary>
		public string Login
		{
			get { return LoginCtrl.Text; }
			set { LoginCtrl.Text = value; }
		}

		/// <summary>
		/// Пароль.
		/// </summary>
		public string Password
		{
			get { return PasswordCtrl.Password; }
			set { PasswordCtrl.Password = value; }
		}

		private void Browse_Click(object sender, RoutedEventArgs e)
		{
			var dlg = new VistaFolderBrowserDialog();

			if (dlg.ShowDialog(this.GetWindow()) == true)
			{
				PathCtrl.Text = dlg.SelectedPath;
			}
		}
	}
}